package com.shm.hello;

import java.util.*;


public class Solution1 {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     * 给定数值的下一个数值
     *
     * @param chars        string字符串一维数组 构成N进制的n个字符
     * @param currentValue string字符串 当前值
     * @return string字符串
     */
    public String nextValue(String[] chars, String currentValue) {
        // write code here
        HashMap<String,String> map = new HashMap<>();
//        ["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],"叁叁"
        map.put("零","0");
        map.put("壹","1");
        map.put("贰","2");
        map.put("叁","3");
        map.put("肆","4");
        map.put("伍","5");
        map.put("陆","6");
        map.put("柒","7");
        map.put("捌","8");
        map.put("玖","9");
        String max = chars[0];
        for (int i = 1; i < chars.length; i++) {
            if (map.containsKey(chars[i])){
                String s = map.get(chars[i]);
                if (Integer.parseInt(s) > Integer.parseInt(max)) {
                    max = s;
                }
            }else {
                if (Integer.parseInt(chars[i]) > Integer.parseInt(max)) {
                    max = chars[i];
                }
            }
        }
        int n = Integer.parseInt(max);
//        char[] dict = {'零','壹','贰','叁','肆','伍','陆','柒','捌','玖'};
//        currentValue.contains(dict);
        int cur = Integer.parseInt(currentValue,n+1);
        return Integer.toString(cur + 1,n+1);
    }
}